package com.fairytask.extention.user;

import com.smartfoxserver.v2.core.ISFSEvent;
import com.smartfoxserver.v2.core.SFSEventParam;
import com.smartfoxserver.v2.exceptions.SFSErrorCode;
import com.smartfoxserver.v2.exceptions.SFSErrorData;
import com.smartfoxserver.v2.exceptions.SFSException;
import com.smartfoxserver.v2.exceptions.SFSLoginException;
import com.smartfoxserver.v2.extensions.BaseServerEventHandler;

public class UserLoginHandler extends BaseServerEventHandler
{
	public UserLoginHandler()
	{
		// TODO Auto-generated constructor stub
	}

	@Override
	public void handleServerEvent(ISFSEvent evt) throws SFSException
	{
		String name = (String) evt.getParameter(SFSEventParam.LOGIN_NAME); 
        
	      if (name.equals("Gonzo") || name.equals("Kermit")) 
	      {
	        // Create the error code to send to the client  
	        SFSErrorData errData = new SFSErrorData(SFSErrorCode.LOGIN_BAD_USERNAME);
	        errData.addParameter(name);
	         
	        // Fire a Login exception
	        throw new SFSLoginException("Gonzo and Kermit are not allowed in this Zone!", errData); 
	      }
	}

}
